<!-- 实物奖品领取记录 -->
<template>
  <page-header-wrapper>
    <a-card class="table-card">
      <GzSearchForm :searchFunc="searchFunc" :resetFunc="onReset" searchConditionNum="6">
        <gz-text-up v-model:value="searchData['goodsId']" :placeholder="'商品ID'" />
        <gz-text-up v-model:value="searchData['activityId']" :placeholder="'活动ID'" />
        <gz-text-up v-model:value="searchData['courierNumber']" :placeholder="'快递单号'" />
        <gz-text-up v-model:value="searchData['address']" :placeholder="'邮寄地址'" />
        <gz-text-up v-model:value="searchData['linkPerson']" :placeholder="'联系人'" />
        <gz-text-up v-model:value="searchData['linkPhone']" :placeholder="'联系电话'" />
      </GzSearchForm>

      <!-- 列表渲染 -->
      <GzTable
        ref="infoTableRef"
        :init-data="true"
        :req-table-data-func="reqTableDataFunc"
        :table-columns="tableColumns"
        :search-data="searchData"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'operation'">
            <!-- 操作列插槽 -->
            <GzTableColumns>
              <a-button type="link" danger>删除</a-button>
            </GzTableColumns>
          </template>
        </template>
      </GzTable>
    </a-card>
  </page-header-wrapper>
</template>
<script setup lang="ts">
import { ref, reactive, getCurrentInstance } from 'vue'
const { $infoBox, $access } = getCurrentInstance()!.appContext.config.globalProperties

const infoTableRef = ref()
let tableColumns = reactive([
  { key: 'goodsId', title: '商品ID',dataIndex: 'goodsId',fixed: 'left', width: 200, minWidth: 150, maxWidth: 250 },
  { key: 'activityId', title: '活动ID',dataIndex: 'activityId', width: 140, minWidth: 140, maxWidth: 170 },
  { key: 'courierNumber', title: '快递单号', dataIndex: 'courierNumber', width: 140, minWidth: 140, maxWidth: 170 },
  { key: 'address', title: '邮寄地址', dataIndex: 'address', width: 140, minWidth: 140, maxWidth: 170 },
  { key: 'linkPerson', title: '联系人', dataIndex: 'linkPerson',  width: 140, minWidth: 140, maxWidth: 170 },
  { key: 'linkPhone', title: '联系电话', dataIndex: 'linkPhone', width: 140, minWidth: 140, maxWidth: 170 },
  { key: 'operation', title: '操作', dataIndex: 'operation',width: 260, fixed: 'right', align: 'center' }
])

const searchData = ref({})

// 请求table接口数据
function reqTableDataFunc(params: any) {
  return new Promise(resolve=>{
    resolve({
      total: 3,
      records: [
        {
          goodsId: 'G2300000',
          activityId: 'A23456',
          courierNumber: 'SF123456498',
          address: '河南省郑州市管城区',
          linkPerson: '李磊',
          linkPhone: '17856566635',
        }
      ]
    })
  })
}

function searchFunc() {
  infoTableRef.value.refTable(true)
}

function onReset() {
  searchData.value = {}
}
</script>
